/*
 * @Author: wwl 2967796480@qq.com
 * @Date: 2023-09-12 11:59:04
 * @LastEditors: wwl 2967796480@qq.com
 * @LastEditTime: 2023-09-14 09:54:18
 * @FilePath: \ConstantBlueCloud_WEB_USER_DZ1 - 副本\src\api\public.ts
 * @Description: 
 * 
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved. 
 */
import Request from '@/libs/request'
import qs from 'qs'

/**web 用户查询设备 检测参数 */
export const uSelectDevParamList = (data: { devId: number }) =>
  Request.get<SimpleParamData[]>('/user/uSelectDevParamList', data)

/**查询用户设备列表 携带计算数据*/
export const uSelectUserDevList = (data: { userId: string | number }) =>
  Request.get<DeviceData[]>('/platFormSubUser/selectDevList', {
    platFormSubUserId: data.userId
  })

/**查询用户设备列表 简单设备列表*/
export const selectSimpleDevList = (data: { userId: string | number }) =>
  Request.get<SimpleDeviceData[]>('/platFormSubUser/selectDevList', {
    platFormSubUserId: data.userId
  })

/* 查询用户设备列表 --- 分页 */
export const selectSimpleDevListPageList = (data: {
  page: number
  size: number
  devName: string
  platFormSubUserId: number
}) => {
  return Request.get<SimpleDeviceData[]>('/platFormSubUser/get/deviceByPage', data)
}

/**获取设备日志类型 */
export const getDevLogType = () => Request.get<Dict[]>('/platFormSubUser/getDevLogType')

/**获取设备日志事件类型 */
export const getDevEventType = () => Request.get<Dict[]>('/platFormSubUser/getDevEventType')

/**用户导出设备日志 */
export const exportDevLog = (data: {
  userId: number | string
  devId?: number
  devLogTypeCode: string
  devEventTypeCode: string
  startDate?: string
  endDate?: string
}) => {
  let reqData = {
    platFormSubUserId: data.userId,
    devId: data.devId,
    devLogTypeCode: data.devLogTypeCode,
    devEventTypeCode: data.devEventTypeCode,
    startDate: data.startDate,
    endDate: data.endDate
  }

  let param = qs.stringify(data)
  return Request.filePost('/platFormSubUser/exportDevLog', param)
}

/**通过字典数据的code查询字典数据 */
export const mSelectItemByCode = (data: { code: string }) =>
  Request.get<Dict>('/platFormSubUser/select/dictItem', data)

/* 查询设备信息的Api */
export const selectDevInfoApi = (data: object) => {
  let param = qs.stringify(data)
  return Request.post('/platFormSubUser/Select/devBaseData', param)
}

/* 修改设备名称的Api */
export const editDevNameApi = (data: any) => {
  let param = qs.stringify(data)
  return Request.post('/platFormSubUser/edit/devName', param)
}



/* 修改设备详细地址的Api */
export const editAddressApi = (data: any) => {
  return Request.post('/platFormSubUser/edit/devAddress', qs.stringify(data))
}

// 修改设备省市区的Api
export const editDevAreaApi = (data: any) => {
  return Request.post('/platFormSubUser/edit/devArea', qs.stringify(data))
}